package net.adst.ui.mainframe.toppanel;

import net.adst.resources.Constants;
import net.adst.util.GBC;

import javax.swing.*;
import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * User: alekseipot
 * Date: 01.11.12
 * Time: 4:48
 * To change this template use File | Settings | File Templates.
 */
public class TopPanel extends JPanel {

    public TopPanel() {       // Do not rename
        setLayout(new GridBagLayout());
        add(new PeriodChooserArea(), new GBC(0, 1, 1, 2).setInsets(5, 5).setAnchor(GBC.NORTHWEST));
        add(new ButtonsArea(), new GBC(1, 1, 1, 1).setAnchor(GBC.NORTHWEST));
        add(new CommentArea(), new GBC(2, 1, 1, 1).setInsets(2, 4, 1, 1).setAnchor(GBC.NORTH).setWeight(1, 0).setFill(GBC.BOTH));
        setColors();
    }

//    public String getComment() {
//        return areaPanel.getComment();
//    }


//    private void addStatusLabels() {
//        Dimension dimension = new Dimension(220, 20);
//        final JLabel issueLabel = new JLabel();
//        issueLabel.setMaximumSize(dimension);
//        issueLabel.setPreferredSize(dimension);
//        issueLabel.setMinimumSize(dimension);
//
//        DataManager.setObject(ResourceManager.getVariableName("ui.topPanel.reportDateArea.task.label"), issueLabel);
//        //ORS-58 fix
//        issueLabel.setText(ResourceManager.getString("ui.top_panel.ReportDateArea.issueIsNotChosen"));
//        LinkLabel test = new LinkLabel();
//        add(issueLabel, new GBC(0, 0, 2, 1).setInsets(5, 5, 0, 5).setAnchor(GBC.WEST));
////        periodLabel = new JLabel(ResourceManager.getString("ui.top_panel.periodLabel"));
//        final JLabel periodLabel = new JLabel();
//        dimension = new Dimension(350, 20);
//        periodLabel.setMaximumSize(dimension);
//        periodLabel.setPreferredSize(dimension);
//        periodLabel.setMinimumSize(dimension);
//        DataManager.setObject(ResourceManager.getVariableName("ui.topPanel.periodLabel"), periodLabel);
//        DataManager.setObject(ResourceManager.getVariableName("calendar.period"), "oooo");
//        add(periodLabel, new GBC(1, 0, 3, 1).setInsets(5, 80, 0, 5).setAnchor(GBC.NORTHWEST));
//    }

    public void setColors() {
        setBackground(Constants.COLOR_LIGHT_BLUE);
        Component[] components = TopPanel.this.getComponents();
        for (Component comp : components) {
            Component[] inComponents = ((Container) comp).getComponents();
            for (Component inComp : inComponents) {
                Component[] inInComponents = ((Container) inComp).getComponents();
                for (Component inInComp : inInComponents) {
                    if (!(inInComp instanceof JComboBox) && !(inInComp instanceof JTextField)) {
                        inInComp.setBackground(Constants.COLOR_LIGHT_BLUE);
                    }
                }
                if (!(inComp instanceof JComboBox) && !(inComp instanceof JTextField)) {
                    inComp.setBackground(Constants.COLOR_LIGHT_BLUE);
                }
            }
            comp.setBackground(Constants.COLOR_LIGHT_BLUE);
        }
    }
}
